<!--
 * @Author: suo.tianbao suo.tianbao@vpclub.cn
 * @Date: 2023-10-11
 * @LastEditors: suo.tianbao suo.tianbao@vpclub.cn
 * @LastEditTime: 2023-10-11
 * @FilePath: /element-admin/src/views/aliyun/VpProduct.vue
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
-->
<template>
  <div id="purn-freelife-page">
    <!--顶部搜索栏-->
    <div class="col-md-12">
      <el-row :gutter="20">
        <el-col :span="20" :offset="1" class="clearfix">
          <el-card class="box-card">
            <template #header>
              <div class="card-header">
                <span style="font-size: 22px;">A.年化投资参数 </span>
                <el-button type="primary" class="button" @click="handle_init" size="small">核查参数</el-button>
              </div>
            </template>
            <el-form :model="FreeL" label-width="140px">
              <el-row :gutter="10">
                <el-col :sm="14" :xs="14" :md="14" :lg="14" :xl="14">
                  <el-form-item label="数据验证key">
                    <el-input v-model="key" readonly></el-input>
                  </el-form-item>
                </el-col>
                <el-col :sm="10" :xs="10" :md="10" :lg="10" :xl="10">
                  <el-form-item label="验证结果">
                    <span>{{ hit_msg }}</span>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-divider content-position="left">投资参数</el-divider>
              <el-row :gutter="10">
                <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">
                  <el-form-item label="次年歲">
                    <el-input v-model="FreeL.select_anb" placeholder="次年歲" size="small" :clearable="true" maxlength="3"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="10">
                <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">
                  <el-form-item label="性別">
                    <el-input v-model="FreeL.gender" placeholder="性別" size="small" :clearable="true" v-show="false"></el-input>
                    <el-radio-group v-model="FreeL.gender">
                      <el-radio :label="opt.value" v-for="opt in gender_options" v-bind:key="opt.key">{{ opt.label }}</el-radio>
                    </el-radio-group>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="10">
                <el-col :sm="12" :xs="12" :md="12" :lg="12" :xl="12">
                  <el-form-item label="吸煙者 (N/S)">
                    <el-input v-model="FreeL.smoker" placeholder="分类名称" size="small" :clearable="true" v-show="false"></el-input>
                    <el-radio-group v-model="FreeL.smoker">
                      <el-radio :label="opt.value" v-for="opt in smoker_options" v-bind:key="opt.key">{{ opt.label }}</el-radio>
                    </el-radio-group>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="10">
                <el-col :sm="12" :xs="12" :md="12" :lg="12" :xl="12">
                  <el-form-item label="使用貨幣">
                    <el-input v-model="FreeL.currency" placeholder="使用貨幣" size="small" :clearable="true" v-show="false"></el-input>
                    <el-radio-group v-model="FreeL.currency">
                      <el-radio :label="opt.value" :title="opt.label" v-for="opt in currency_options" v-bind:key="opt.key"></el-radio>
                    </el-radio-group>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="10">
                <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">
                  <el-form-item label="投资額">
                    <el-input v-model="FreeL.sum_assured" placeholder="投资額" size="small" :clearable="true"
                              maxlength="9"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">
                  <el-form-item label="供款期">
                    <el-tooltip class="item" effect="dark" content="投入资金使用年数" placement="right">
                      <el-select v-model="FreeL.select_payment" placeholder="供款期" size="small">
                        <el-option label="请选择" value=0></el-option>
                        <el-option :label="item.label" :value=item.value :data="item" v-for="item in select_payment_options"
                                   v-bind:key="item.value"></el-option>
                      </el-select>
                    </el-tooltip>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="10">
                <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">
                  <el-form-item label="提取開始次年歲">
                    <el-input v-model="FreeL.withdrawal_starting_anb" placeholder="提取開始次年歲" size="small"
                              :clearable="true"></el-input>
                  </el-form-item>
                </el-col>
                <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">
                  <el-form-item label="退额次年歲">
                    <el-tooltip class="item" effect="dark" content="放弃投资，申请退款次年岁" placement="right">
                      <el-input v-model="FreeL.surrender_anb" placeholder="退额次年歲" size="small"
                                :clearable="true"></el-input>
                    </el-tooltip>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="10">
                <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">
                  <el-form-item label="首年提款">
                    <el-tooltip class="item" effect="dark" content="计算提现申请的主要计算因子" placement="right">
                      <el-input v-model="FreeL.fst_year_withdrawal" placeholder="首年提款" size="small"
                                :clearable="true"></el-input>
                    </el-tooltip>
                  </el-form-item>
                </el-col>
                <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">
                  <el-form-item label="提取年期">
                    <el-input v-model="FreeL.withdrawal_years" placeholder="提取年期" size="small"
                              :clearable="true"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="10">
                <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">
                  <el-form-item label="通脹率">
                    <el-input v-model="FreeL.inflation" placeholder="通脹率" size="small" :clearable="true"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="10">
                <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">
                  <el-form-item label="複投年數">
                    <el-tooltip class="item" effect="dark" content="到期后重复投入" placement="right">
                      <el-select v-model="FreeL.repeat_plan" placeholder="複投年數" size="small">
                        <el-option label="请选择" value=-1></el-option>
                        <el-option :label="item.label" :value=item.value :data="item" v-for="item in repeat_plan_options"
                                   v-bind:key="item.value"></el-option>
                      </el-select>
                    </el-tooltip>
                  </el-form-item>
                </el-col>
                <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">
                  <el-form-item label="複投利率">
                    <el-input v-model="FreeL.repeat_growth_rate" placeholder="複投利率" size="small"
                              :clearable="true"></el-input>
                  </el-form-item>
                </el-col>
              </el-row>
              <el-row :gutter="10">
                <el-col :sm="24" :xs="24" :md="24" :lg="24" :xl="24">
                  <el-form-item label="是否加入推廣優惠">
                    <el-switch v-model="FreeL.promotion"/>
                    <span style="margin-left: 15px">(tips:加入选择优惠影响次年投资额的返现金额)</span>
                  </el-form-item>
                </el-col>
              </el-row>
            </el-form>
          </el-card>
        </el-col>
      </el-row>
    </div>
    <!--中部数据表格栏-->
    <div class="col-md-12" style="margin-top: 25px">
      <el-row :gutter="20">
        <el-col :span="22" :offset="1" class="clearfix">
          <el-card class="box-card" style="margin-bottom: 15px">
            <template #header>
              <div class="card-header">
                <span style="font-size: 22px;">B.年化产品投资核算 </span>
                <!-- <el-button type="primary" class="button" @click="handle_cal" size="small" disabled>執行計算</el-button>-->
                <el-button type="info" class="button" @click.native="handleDisplayChoose" size="small">选择展示内容</el-button>
              </div>
            </template>
            <div>
              <div style="margin-bottom: 15px"><span>結算貨幣:</span><span style="margin-left: 15px">{{FreeL.currency}}</span></div>
              <el-table :header-cell-style="{background: '#eef1f6', color:'#606266'}"
                        :data="tableData" :cell-style="{padding:'3px'}" :row-style="{height:'30px'}" :max-height="tableHeight"
                        :key="isIndex" style="width: 100%" v-loading="isLoading" border stripe row-key="id">
                <el-table-column fixed type="index" label="序号" width="65px" v-if="false"></el-table-column>
                <el-table-column fixed prop="chgtab_Year_res" label="年期" width="65px"/>
                <el-table-column fixed prop="chgtab_ANB_res" label="次年歲" width="65px"/>
                <el-table-column fixed prop="chgtab_Annual_Contribution_res" v-bind:label="'每年供款'"/>
                <el-table-column fixed prop="chgtab_Extra_Withdrawal_res" v-bind:label="'額外提取'">
                  <template slot-scope="scope">
                    <el-input v-model="scope.row.chgtab_Extra_Withdrawal_res"
                              @change.native="handleAddParam(scope.row)"
                              @clear="handleClrParam(scope.row)"
                              placeholder="額外提取" size="small" :clearable="true" maxlength="9">
                    </el-input>
                  </template>
                </el-table-column>
                <el-table-column fixed prop="chgtab_Total_Withdrawal_res" v-bind:label="'總提取'"/>
                <el-table-column fixed prop="chgtab_Cumulative_Withdrawal_res" v-bind:label="'累積提取'"/>
                <el-table-column fixed prop="chgtab_Balance_res" v-bind:label="'餘額'"/>
                <el-table-column fixed prop="chgtab_Death_Benefit_res" v-bind:label="'身故賠償'"/>
                <el-table-column fixed prop="Cashflow_res" label="现金流" width="130px"/>
                <el-table-column prop="bonus_base_res" label="bonus_base" v-if="checkColumnShow('bonus_base_res')"/>
                <el-table-column prop="bonus_rate_res" label="bonus_rate" v-if="checkColumnShow('bonus_rate_res')"/>
                <el-table-column prop="bonus_res" label="bonus" v-if="checkColumnShow('bonus_res')"/>
                <el-table-column prop="death_res" label="death" v-if="checkColumnShow('death_res')"/>
                <el-table-column prop="GCV_base_res" label="GCV_base" v-if="checkColumnShow('GCV_base_res')"/>
                <el-table-column prop="GCV_rate_res" label="GCV_rate" v-if="checkColumnShow('GCV_rate_res')"/>
                <el-table-column prop="GCV_value_res" label="GCV_value" v-if="checkColumnShow('GCV_value_res')"/>
                <el-table-column prop="CV_res" label="CV" v-if="checkColumnShow('CV_res')"/>
                <el-table-column prop="SA_0_res" label="SA_0" v-if="checkColumnShow('SA_0_res')"/>
                <el-table-column prop="SA_1_res" label="SA_1" v-if="checkColumnShow('SA_1_res')"/>
                <el-table-column prop="SA_2_res" label="SA_2" v-if="checkColumnShow('SA_2_res')"/>
                <el-table-column prop="SA_3_res" label="SA_3" v-if="checkColumnShow('SA_3_res')"/>
                <el-table-column prop="SA_4_res" label="SA_4" v-if="checkColumnShow('SA_4_res')"/>
                <el-table-column prop="SA_5_res" label="SA_5" v-if="checkColumnShow('SA_5_res')"/>
                <el-table-column prop="Total_min_SA_res" label="Total_min_SA" v-if="checkColumnShow('Total_min_SA_res')"/>
                <el-table-column prop="Running_SA_res" label="Running_SA" v-if="checkColumnShow('Running_SA_res')"/>
                <el-table-column prop="SA_too_low_res" label="SA_too_low" v-if="checkColumnShow('SA_too_low_res')"/>
                <el-table-column prop="Year_res" label="Year" v-if="checkColumnShow('Year_res')"/>
                <el-table-column prop="Rebate_res" label="Rebate" v-if="checkColumnShow('Rebate_res')"/>
                <el-table-column prop="EGS_premium_res" label="EGS_premium" v-if="checkColumnShow('EGS_premium_res')"/>
                <el-table-column prop="Cumulative_premium_res" label="Cumulative_premium" v-if="checkColumnShow('Cumulative_premium_res')"/>
                <el-table-column prop="Re_adjusted_CV_res" label="Re_adjusted_CV" v-if="checkColumnShow('Re_adjusted_CV_res')"/>
                <el-table-column prop="Annual_withdrawal_res" label="Annual_withdrawal" v-if="checkColumnShow('Annual_withdrawal_res')"/>
                <el-table-column prop="Remain_res" label="Remain" v-if="checkColumnShow('Remain_res')"/>
                <el-table-column prop="Balance_res" label="Balance" v-if="checkColumnShow('Balance_res')"/>
                <el-table-column prop="LFREE_premium_res" label="LFREE_premium" v-if="checkColumnShow('LFREE_premium_res')"/>
                <el-table-column prop="LFREE_CV_res" label="LFREE_CV" v-if="checkColumnShow('LFREE_CV_res')"/>
                <el-table-column prop="Adjusted_EGS_CV_res" label="Adjusted_EGS_CV" v-if="checkColumnShow('Adjusted_EGS_CV_res')"/>
                <el-table-column prop="A_EGS_CV_1_res" label="A_EGS_CV_1" v-if="checkColumnShow('A_EGS_CV_1_res')"/>
                <el-table-column prop="A_EGS_CV_2_res" label="A_EGS_CV_2" v-if="checkColumnShow('A_EGS_CV_2_res')"/>
                <el-table-column prop="A_EGS_CV_3_res" label="A_EGS_CV_3" v-if="checkColumnShow('A_EGS_CV_3_res')"/>
                <el-table-column prop="A_EGS_CV_4_res" label="A_EGS_CV_4" v-if="checkColumnShow('A_EGS_CV_4_res')"/>
                <el-table-column prop="A_EGS_CV_5_res" label="A_EGS_CV_5" v-if="checkColumnShow('A_EGS_CV_5_res')"/>
                <el-table-column prop="Total_A_EGS_CV_res" label="Total_A_EGS_CV" v-if="checkColumnShow('Total_A_EGS_CV_res')"/>
                <el-table-column prop="Balance_before_withdraw_res" label="Balance_before_withdraw"
                                 v-if="checkColumnShow('Balance_before_withdraw_res')"/>
                <el-table-column prop="Retired_res" label="Retired" v-if="checkColumnShow('Retired_res')"/>
                <el-table-column prop="Income_res" label="Income" v-if="checkColumnShow('Income_res')"/>
                <el-table-column prop="Inflation_factor_res" label="Inflation_factor" v-if="checkColumnShow('Inflation_factor_res')"/>
                <el-table-column prop="Inflated_income_res" label="Inflated_income" v-if="checkColumnShow('Inflated_income_res')"/>
                <el-table-column prop="Withdrawal_res" label="Withdrawal" v-if="checkColumnShow('Withdrawal_res')"/>
                <el-table-column prop="Cashflow_res" label="Cashflow" v-if="checkColumnShow('Cashflow_res')"/>
              </el-table>
            </div>
          </el-card>
        </el-col>
      </el-row>
    </div>
    <el-dialog title="展示数据列" :visible.sync="dialogVisible" width="75%" :before-close="handleClose">
      <el-card class="box-card" style="margin-bottom: 15px">
        <template #header>
          <div class="card-header">
            <span style="font-size: 22px;">展示数据列 </span>
            <el-button type="info" class="button" @click.native="handleResetChoose" size="small">一键恢复</el-button>
          </div>
        </template>
        <div>
          <el-form :inline="true" :model="query" >
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.bonus_base_res" active-text="bonus_base_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.bonus_rate_res" active-text="bonus_rate_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.bonus_res" active-text="bonus_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.death_res" active-text="death_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.GCV_base_res" active-text="GCV_base_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.GCV_rate_res" active-text="GCV_rate_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.GCV_value_res" active-text="GCV_value_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.CV_res" active-text="CV_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.SA_0_res" active-text="SA_0_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.SA_1_res" active-text="SA_1_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.SA_2_res" active-text="SA_2_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.SA_3_res" active-text="SA_3_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.SA_4_res" active-text="SA_4_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.SA_5_res" active-text="SA_5_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.Total_min_SA_res" active-text="Total_min_SA_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.Running_SA_res" active-text="Running_SA_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.SA_too_low_res" active-text="SA_too_low_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.Year_res" active-text="Year_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.Rebate_res" active-text="Rebate_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.EGS_premium_res" active-text="EGS_premium_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.Cumulative_premium_res" active-text="Cumulative_premium_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.Re_adjusted_CV_res" active-text="Re_adjusted_CV_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.Annual_withdrawal_res" active-text="Annual_withdrawal_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.Remain_res" active-text="Remain_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.Balance_res" active-text="Balance_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.LFREE_premium_res" active-text="LFREE_premium_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.LFREE_CV_res" active-text="LFREE_CV_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.Adjusted_EGS_CV_res" active-text="Adjusted_EGS_CV_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.A_EGS_CV_1_res" active-text="A_EGS_CV_1_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.A_EGS_CV_2_res" active-text="A_EGS_CV_2_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.A_EGS_CV_3_res" active-text="A_EGS_CV_3_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.A_EGS_CV_4_res" active-text="A_EGS_CV_4_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.A_EGS_CV_5_res" active-text="A_EGS_CV_5_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.Total_A_EGS_CV_res" active-text="Total_A_EGS_CV_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.Balance_before_withdraw_res" active-text="Balance_before_withdraw_res" inactive-text="off" size="small"  style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.Retired_res" active-text="Retired_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.Income_res" active-text="Income_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.Inflation_factor_res" active-text="Inflation_factor_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.Inflated_income_res" active-text="Inflated_income_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.Withdrawal_res" active-text="Withdrawal_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
            <el-col :sm="8" :xs="8" :md="8" :lg="8" :xl="8">	<el-form-item>	<el-switch v-model="extra_column.Cashflow_res" active-text="Cashflow_res" inactive-text="off" size="small" style="--el-switch-on-color: #13ce66; --el-switch-off-color: #ff4949"/>	</el-form-item>	</el-col>
          </el-form>
        </div>
      </el-card>
    </el-dialog>
  </div>
</template>
<script>
import {mapMutations} from "vuex";
import {calParam, initBaseStdTab, initParam} from "@/api/PurmFreelifeApi";
import {Message} from 'element-ui';

export default {
  name: "PurmFreelifeView",
  components: {},
  data() {
    return {
      isIndex: 1,
      isLoading: false,
      dialogVisible: false,
      key: '',
      hit_msg: '',
      tableHeight: 650,
      FreeL: {
        select_payment: 10,
        select_anb: 7,
        sum_assured: '1000000',
        gender: 'M',
        smoker: 'N',
        repeat_plan: 5,
        repeat_growth_rate: 1 / 100,
        currency: 'HKD',
        promotion: true,
        withdrawal_starting_anb: 66,
        surrender_anb: 91,
        withdrawal_years: 0,
        inflation: 0 / 100,
        fst_year_withdrawal: 0,
      },
      tableData: [{
        chgtab_Year_res: 0,
        chgtab_ANB_res: 0,
        chgtab_Annual_Contribution_res: 0,
        chgtab_Extra_Withdrawal_res: 0,
        chgtab_Total_Withdrawal_res: 0,
        chgtab_Cumulative_Withdrawal_res: 0,
        chgtab_Balance_res: 0,
        chgtab_Death_Benefit_res: 0,
        Cashflow_res: 0,
      }],
      gender_options: [
        {label: "男性", value: "M", key: "M"},
        {label: "女性", value: "F", key: "F"}
      ],
      smoker_options: [
        {label: "吸煙者", value: "S", key: "S"},
        {label: "非吸煙者", value: "N", key: "N"}
      ],
      select_payment_options: [
        {label: "1", value: 1, key: 1},
        {label: "10", value: 10, key: 10},
        {label: "20", value: 20, key: 20},
        {label: "30", value: 30, key: 30}
      ],
      currency_options: [
        {label: "USD", value: "USD", key: "USD"},
        {label: "HKD", value: "HKD", key: "HKD"},
        {label: "RMB", value: "RMB", key: "RMB"}
      ],
      promotion_options: [
        {label: "Y", value: "Y", key: "Y"},
        {label: "N", value: "N", key: "N"}
      ],
      repeat_plan_options: [
        {label: "0", value: 0, key: "0"},
        {label: "1", value: 1, key: "1"},
        {label: "2", value: 2, key: "2"},
        {label: "3", value: 3, key: "3"},
        {label: "4", value: 4, key: "4"},
        {label: "5", value: 5, key: "5"}
      ],
      query: {
        strPram: '',
        withdrawals: [],
      },
      input_Extra_Withdrawal: [],
      extra_column: {
        bonus_base_res: 0,
        bonus_rate_res: 0,
        bonus_res: 0,
        death_res: 0,
        GCV_base_res: 0,
        GCV_rate_res: 0,
        GCV_value_res: 0,
        CV_res: 0,
        SA_0_res: 0,
        SA_1_res: 0,
        SA_2_res: 0,
        SA_3_res: 0,
        SA_4_res: 0,
        SA_5_res: 0,
        Total_min_SA_res: 0,
        Running_SA_res: 0,
        SA_too_low_res: 0,
        Year_res: 0,
        Rebate_res: 0,
        EGS_premium_res: 0,
        Cumulative_premium_res: 0,
        Re_adjusted_CV_res: 0,
        Annual_withdrawal_res: 0,
        Remain_res: 0,
        Balance_res: 0,
        LFREE_premium_res: 0,
        LFREE_CV_res: 0,
        Adjusted_EGS_CV_res: 0,
        A_EGS_CV_1_res: 0,
        A_EGS_CV_2_res: 0,
        A_EGS_CV_3_res: 0,
        A_EGS_CV_4_res: 0,
        A_EGS_CV_5_res: 0,
        Total_A_EGS_CV_res: 0,
        Balance_before_withdraw_res: 0,
        Retired_res: 0,
        Income_res: 0,
        Inflation_factor_res: 0,
        Inflated_income_res: 0,
        Withdrawal_res: 0,
        Cashflow_res: 0,
      }
    }
  },
  computed: {},
  methods: {
    ...mapMutations(['add_tab']),
    handleFetch() {
      this.isLoading = true;
      this.handle_init();
    },
    handle_init() {
      this.tableData = [];
      initParam(this.FreeL).then(res => {
        let _res = eval(res.data);
        this.key = _res.key;
        this.hit_msg = _res.res_msg;
        // 发起参数核算
        this.query.strPram = _res.key;
        this.isLoading = true;
        initBaseStdTab(this.query).then(res => {
          if (res.code == 200) {
            this.isLoading = false;
            this.tableData = res.data;
            // Message.success("参数核算完成")
            this.$notify({
              title: '执行成功',
              message: '参数核算完成',
              type: 'success',
              offset: 100
            });
          }
        }).catch(err => {
          // Message.error('错了哦，STEP 2 参数核算异常' + err);
          this.$notify({
            title: '执行成功',
            message: '系统异常，执行 STEP 2 初始化年化产品投资核算异常' + err,
            type: 'error',
            offset: 100
          });
        })
      }).catch(err => {
        // Message.error('系统异常，STEP 1 参数异常' + err);
        this.$notify({
          title: '执行成功',
          message: '系统异常，执行 STEP 1 投资参数解析异常' + err,
          type: 'error',
          offset: 100
        });
      })
      this.input_Extra_Withdrawal = [];
    },
    handle_cal() {
      this.isLoading = true;
      this.tableData = [];
      this.query.strPram = this.key;
      this.query.withdrawals = this.input_Extra_Withdrawal;
      if (this.query.strPram == null || this.query.strPram.length == 0) {
        // Message.error('错了哦，参数核算不能空白');
        this.$notify({
          title: '警告',
          message: '系统异常，执行参数核算【数据验证key】不能空，请执行【核查参数】',
          type: 'warning',
          offset: 100
        });
        this.isLoading = false;
        return
      } else {
        calParam(this.query).then(res => {
          if (res.code == 200) {
            this.isLoading = false;
            this.tableData = res.data;
            // Message.success("参数核算完成")
            this.$notify({
              title: '执行成功',
              message: '提现数据计算完成',
              type: 'success',
              offset: 100
            });
          }
        }).catch(err => {
          Message.error('错了哦，STEP 2 参数核算异常' + err);
        })
      }
    },
    handleAddParam(row) {
      this.isLoading = true;
      let add = true;
      if (parseInt(row.chgtab_Extra_Withdrawal_res) > 0) {
        this.input_Extra_Withdrawal.forEach(item => {
          if (parseInt(item.anb) == parseInt(row.chgtab_ANB_res)) {
            add = false;
          }
        });
        if (add) {
          this.input_Extra_Withdrawal.push({"anb": parseInt(row.chgtab_ANB_res), "withdrawal": parseInt(row.chgtab_Extra_Withdrawal_res)})
        }
      }
      this.handle_cal();
    },
    handleClrParam(row) {
      let tmp = []
      this.input_Extra_Withdrawal.forEach(item => {
        if (parseInt(item.anb) != parseInt(row.chgtab_ANB_res)) {
          tmp.push(item);
        }
      });
      this.input_Extra_Withdrawal = tmp;
      row.chgtab_Extra_Withdrawal_res = 0;
    },
    handleDisplayChoose() {
      this.dialogVisible = true;
    },
    handleClose() {
      this.dialogVisible = false;
    },
    checkColumnShow(check_key) {
      return this.extra_column[check_key] == 1
    },
  },
  created() {
    // this.handle_init();
  },
  mounted() {
  },
}
</script>
<style scoped>
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.custRow {
  display: flex;
  margin-top: 5px;
  padding: 5px 5px 5px 5px;
}
</style>